#!/bin/bash

if [[ $1 == '' ]];then
    #echo "Usage: ./install.sh PackageName"
    package="common"
else
    package=$(echo $1 | tr [A-Z] [a-z])
fi


function setCommon(){
echo -e '\n\n'
printInfo "Set Common"
echo "sudo apt-get install vim subversion git screen apache2 mysql-client mysql-server"
sudo apt-get install vim subversion git screen apache2 mysql-client mysql-server
}
function setPython(){
echo -e '\n\n'
printInfo "Set Python"
sudo apt-get install pep8 pyflakes
echo "sudo apt-get install pep8 pyflakes"
}
function setC(){
echo -e '\n\n'
printInfo "Set C/C++"
sudo apt-get install build-essential exuberant-ctags cmake
echo "sudo apt-get install build-essential exuberant-ctags cmake"
}

function setPHP(){
echo -e '\n\n'
printInfo "Set PHP"
sudo apt-get install php5 php5-mysql phpmyadmin
echo "sudo apt-get install php5 php5-mysql phpmyadmin"
}

function printInfo(){
echo -e "\033[32;49;1m [$1] \033[39;49;0m"
}

function setDjango(){
sudo apt-get install python-pip
sudo apt-get install python-mysqldb
sudo pip install Django
sudo pip install virtualenv
sudo pip install virtualenvwrapper
}
#TODO 利用数组而不是函数来完成配置

setCommon

if [[ $package == 'python' ]];then
    setPython
elif [[ $package == 'c' ]];then
    echo "setC"
    setC
elif [[ $package == 'django' ]];then
    setDjango
elif [[ $package == 'php' ]]; then
    setPHP
elif [[ $package == 'all' ]];then
    setPython
    setC
    setDjango
    setPHP
fi
